package View;

import javafx.scene.Cursor;
import javafx.scene.Parent;
import javafx.scene.image.Image;
import javafx.stage.Stage;
//所有窗口的父类，里面包含方法
public abstract class window extends Stage {
    Parent root;
    private double x;
    private double y;

    public void setIcon(){

        getIcons().add(new Image(getClass().getResourceAsStream("/Picture/sourceMaterial/图标.png")));

    }
    //窗口移动方法
    public void move() {
        root.setOnMousePressed(event -> {

            x= getX() - event.getScreenX();
            y= getY() - event.getScreenY();
            getRoot().setCursor(Cursor.CLOSED_HAND);

        });
        root.setOnMouseDragged(event -> {

            setX(event.getScreenX() + x);
            setY(event.getScreenY() + y);


        });
        root.setOnMouseReleased(event -> {
            root.setCursor(Cursor.DEFAULT);

        });
    }
   //窗口退出
    abstract public void quit();
    //窗口最下化
    abstract public void minimiser();

   //获取窗口root
    public Parent getRoot() {
        return root;
    }

   //获取窗口元素，组件
    public Object $(String id) {
        return (Object) root.lookup("#" + id);
    }


}
